package org.shreker.shan.core.queryobject;

import java.text.ParseException;
import java.util.Date;
import org.shreker.shan.base.queryobject.QueryObject;
import org.shreker.shan.core.domain.Log;
import org.shreker.shan.core.util.DateUtil;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class WebLogQueryObject extends QueryObject {

	private Date beginTime;
	private Date endTime;
	private Integer result = Log.LOG_ALL;
	private Long userId;

	// @DateTimeFormat要求参数必须不为空
	//@DateTimeFormat(pattern="yyyy-MM-dd")
	public void setBeginTime(Date beginTime) {
		this.beginTime = beginTime;
	}
	
	//@DateTimeFormat(pattern="yyyy-MM-dd")
	public void setEndTime(Date endTime) {
		// 把结束时间矫正到这一天的最后一秒
		try {
			this.endTime = DateUtil.convertDate2LastSecond(endTime);
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}

	@Override
	public String toString() {
		return super.toString() + "\nWebLogQueryObject [beginTime=" + beginTime + ", endTime=" + endTime + ", result=" + result + "]";
	}

}
